From: Bryan O'Donoghue Date: Wed, 30 May 2018 18:56:54 +0000 (+0100) Subject: imx: imx_clock: uart: Add UART clock API X-Git-Url: http://git.openwrt.org/%22https:/collectd.org//%22/%22https:/collectd.org/%22?a=commitdiff_plain;h=dcd54e9b4cbe0e771e63f0e53f2d3a59198b48d3;p=project%2Fbcm63xx%2Fatf.git imx: imx_clock: uart: Add UART clock API This patch adds an API to configure up the base UART clocks, taking a bit-mask of silicon specific bits as an input from a higher layer in order to direct the necessary clock source. Signed-off-by: Bryan O'Donoghue --- diff --git a/plat/imx/common/imx_clock.c b/plat/imx/common/imx_clock.c index 929cf8d3..8fb42e3e 100644 --- a/plat/imx/common/imx_clock.c +++ b/plat/imx/common/imx_clock.c @@ -50,3 +50,35 @@ void imx_clock_gate_enable(unsigned int id, bool enable) mmio_write_32(addr, CCM_CCGR_SETTING0_DOM_CLK_ALWAYS); } + +void imx_clock_enable_uart(unsigned int uart_id, uint32_t uart_clk_en_bits) +{ + unsigned int ccm_trgt_id = CCM_TRT_ID_UART1_CLK_ROOT + uart_id; + unsigned int ccm_ccgr_id = CCM_CCGR_ID_UART1 + uart_id; + + /* Check for error */ + if (uart_id > MXC_MAX_UART_NUM) + return; + + /* Set target register values */ + imx_clock_target_set(ccm_trgt_id, uart_clk_en_bits); + + /* Enable the clock gate */ + imx_clock_gate_enable(ccm_ccgr_id, true); +} + +void imx_clock_disable_uart(unsigned int uart_id) +{ + unsigned int ccm_trgt_id = CCM_TRT_ID_UART1_CLK_ROOT + uart_id; + unsigned int ccm_ccgr_id = CCM_CCGR_ID_UART1 + uart_id; + + /* Check for error */ + if (uart_id > MXC_MAX_UART_NUM) + return; + + /* Disable the clock gate */ + imx_clock_gate_enable(ccm_ccgr_id, false); + + /* Clear the target */ + imx_clock_target_clr(ccm_trgt_id, 0xFFFFFFFF); +} diff --git a/plat/imx/common/include/imx_clock.h b/plat/imx/common/include/imx_clock.h index f685a143..f1d1912d 100644 --- a/plat/imx/common/include/imx_clock.h +++ b/plat/imx/common/include/imx_clock.h @@ -989,4 +989,7 @@ void imx_clock_gate_enable(unsigned int id, bool enable); void imx_clock_init(void); +void imx_clock_enable_uart(unsigned int uart_id, uint32_t uart_clk_en_bits); +void imx_clock_disable_uart(unsigned int uart_id); + #endif /* __IMX_CLOCK_H__ */